package j02zhengze;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class J3all {
    public static void main(String[] args) {
        Pattern p1 = Pattern.compile("a.c");
        Matcher m = p1.matcher("axc");
        boolean b1 = m.matches();
        System.out.println("b1 = " + b1);

        System.out.println("axc".matches("a.c"));
        System.out.println("==\\d==");
        System.out.println("a2b".matches("a[0-9]b"));
        System.out.println("a2b".matches("a\\db"));
        System.out.println("  a".matches("\\s+a"));//true
        System.out.println("a".matches("\\s+a"));//false
        System.out.println("====");
        System.out.println(Pattern.matches("a\\sc","axc"));//false
        System.out.println(Pattern.matches("a\\sc","a\tc"));//true

        System.out.println("====");
        String str = "a1btreryea7bdgfatbdgfa9b";
        System.out.println(str.replaceAll("a\\db","_"));

        System.out.println("===find==");

    }
}

class J4{
    public static void main(String[] args) {
        String str = "a1btreryea7bdgfatbdgfa9b";
        //a数字b
        System.out.println("===find==");

        Pattern p = Pattern.compile("a\\db");
        Matcher m = p.matcher(str);

        //查找
        while (m.find()){
            System.out.println(m.group());
        }
        System.out.println("==end==");
//        m.find();
//        System.out.println(m.group());
//        m.find();
//        System.out.println(m.group());
//        m.find();
//        System.out.println(m.group());
//        m.find();
//        System.out.println(m.group());
//        m.find();
//        System.out.println(m.group());
//        m.find();
//        System.out.println(m.group());
    }
}

class J5{
    public static void main(String[] args) {
        System.out.println("abc".matches("^[a-z]+$"));
        System.out.println("abc3".matches("^[a-z]+$"));
    }
}